import Vue from 'vue'  //引入vue
import Vuex from 'vuex'  // 引入vuex
Vue.use(Vuex)   // 注册vuex

import mutations from './mutation'
import createPersistedstate from 'vuex-persistedstate'

const state = {  // 相当于vue里data 存放整个项目的各个状态
  user: null,
  menu: null,
  isManager:false,
}

export default new Vuex.Store({  // 暴露与new vuex
  state,
  mutations,
  plugins: [
    createPersistedstate({
      storage: {
        getItem: key => wx.getStorageSync(key),
        setItem: (key, value) => wx.setStorageSync(key, value),
        removeItem: key => {}
        // removeItem: key => wx.clearStorage(key),
      }
    })
  ]
})
